package designpattern.template;

/**
 * 模板方法抽象类
 *
 * @author bingo
 * @create 2017-12-08 21:15
 **/
public abstract class HummerModel {

    /**模板模式中，基本方法尽量设置为protected，符合迪米特法则，实现类若非必要，尽量不要扩大父类的访问权限*/

    protected   boolean isAlarm=false;

    protected abstract  void start();

    protected abstract  void stop();

    protected abstract  void alarm();

    protected abstract  void engineBoom();

    private boolean isAlarm(Boolean flag){
        this.isAlarm=flag;
        return flag;
        }
    public void run(){
        this.start();
        this.stop();
        if(isAlarm){
            this.alarm();
        }
        this.engineBoom();

    }


}
